package core.models;

import java.io.IOException;

import net.SSHConnection;
import net.SSHConnectionProxy;

public class IfaceStat {
	private String name;
	private long bytesReceived;
	private long packetsReceived;
	private long bytesSent;
	private long packetsSent;
	
	public IfaceStat(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getBytesReceived() {
		return bytesReceived;
	}
	
	public double getMegaBytesReceived() {
		return bytesReceived / 1048576.0;
	}

	public void setBytesReceived(long bytesReceived) {
		this.bytesReceived = bytesReceived;
	}

	public long getPacketsReceived() {
		return packetsReceived;
	}

	public void setPacketsReceived(long packetsReceived) {
		this.packetsReceived = packetsReceived;
	}

	public long getBytesSent() {
		return bytesSent;
	}
	
	public double getMegaBytesSent() {
		return bytesSent / 1048576.0;
	}

	public void setBytesSent(long bytesSent) {
		this.bytesSent = bytesSent;
	}

	public long getPacketsSent() {
		return packetsSent;
	}

	public void setPacketsSent(long packetsSent) {
		this.packetsSent = packetsSent;
	}
	
	public void populateData() throws IOException {
		SSHConnection conn = new SSHConnectionProxy();
		this.bytesReceived = conn.getReceivedBytes(name);
		this.bytesSent = conn.getSentBytes(name);
		this.packetsReceived = conn.getReceivedPackets(name);
		this.packetsSent = conn.getSentPackets(name);
	}
}
